﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JTicket.BLL;
using CrystalDecisions.Shared;

namespace JTicket.UI
{
    public partial class JT_ReportMx : RoleBase
    {
        private readonly BLL.D_OperInfo bllOper = new BLL.D_OperInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            JTicket.Config.DBConfig.CryLogin(
                Server.MapPath("Report\\Reprot3.rpt"), this.CrystalReportSource1);
            if (!IsPostBack)
            {
                this.TextBox1.Text = DateTime.Now.ToString("yyyy-MM-dd");
                this.TextBox2.Text = DateTime.Now.ToString("yyyy-MM-dd"); 
                this.TextBox3.Text = DateTime.Now.ToString("yyyy-MM-dd");
                this.TextBox4.Text = DateTime.Now.ToString("yyyy-MM-dd");
            }
        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            string btime = this.TextBox1.Text;
            string etime = this.TextBox2.Text;
            List<Model.D_TitleInfo> tileList = BLL.D_TitleInfo.
                 GestListAll(bllOper.Oper().ThCode,
                 DateTime.Parse(btime), DateTime.Parse(etime));
            this.DropDownList1.DataSource = tileList;
            this.DropDownList1.DataTextField = "Stitlename";
            this.DropDownList1.DataValueField = "StitleCode";
            this.DropDownList1.DataBind();
        }

        protected void TextBox2_TextChanged(object sender, EventArgs e)
        {
            string btime = this.TextBox1.Text;
            string etime = this.TextBox2.Text;
            List<Model.D_TitleInfo> tileList = BLL.D_TitleInfo.
               GestListAll(bllOper.Oper().ThCode,
               DateTime.Parse(btime), DateTime.Parse(etime));
            this.DropDownList1.DataSource = tileList;
            this.DropDownList1.DataTextField = "Stitlename";
            this.DropDownList1.DataValueField = "StitleCode";
            this.DropDownList1.DataBind();

        }
        protected void Button1_Click(object sender, EventArgs e)
        {

            if (DropDownList1.Items.Count <= 0)
            {
                Common.JsMsg.Alert("选择一个演出项目");
            }
            else
            {

                string Stitlecode = DropDownList1.SelectedItem.Value;
                Model.D_OperInfo model = bllOper.Oper();
                string CurLevel = model.CurLevel.Value.ToString();
                string thcode = model.ThCode.ToString();

                ParameterFields parameterFields = CrystalReportViewer1.ParameterFieldInfo;
                JTicket.Config.DBConfig.SetCurrentValuesForParameterField
                    (parameterFields, this.TextBox1.Text, "@Par1");
                ParameterFields parameterFields1 = CrystalReportViewer1.ParameterFieldInfo;
                JTicket.Config.DBConfig.SetCurrentValuesForParameterField
                    (parameterFields1, this.TextBox2.Text, "@Par2");
                ParameterFields parameterFields2 = CrystalReportViewer1.ParameterFieldInfo;
                JTicket.Config.DBConfig.SetCurrentValuesForParameterField
                    (parameterFields2, "", "@Par3");
                ParameterFields parameterFields3 = CrystalReportViewer1.ParameterFieldInfo;
                JTicket.Config.DBConfig.SetCurrentValuesForParameterField
                    (parameterFields3, Stitlecode, "@Par4");
                ParameterFields parameterFields4 = CrystalReportViewer1.ParameterFieldInfo;
                JTicket.Config.DBConfig.SetCurrentValuesForParameterField
                    (parameterFields4, "", "@Leve");
                ParameterFields parameterFields5 = CrystalReportViewer1.ParameterFieldInfo;
                JTicket.Config.DBConfig.SetCurrentValuesForParameterField
                    (parameterFields5, "R3", "@Model");
                ParameterFields parameterFields6 = CrystalReportViewer1.ParameterFieldInfo;
                JTicket.Config.DBConfig.SetCurrentValuesForParameterField
                    (parameterFields5, DropDownList1.SelectedItem.Text, "@Title");

                this.CrystalReportSource1.DataBind();
            }
        }
    }
}